import axios from 'axios'
import { BASE_URL } from './ApiCons'
import type  {User} from '@/modle/User'

export function login(data:User):Promise<any> {

   return axios.post(BASE_URL + '/user/login',data)
    
}

export function register(data:User):Promise<any> {

    return axios.post(BASE_URL + '/user/register',data)
 }

 export const order = (userName:string,bookId:any | string,num:number | string) => {
   return axios.post(
      BASE_URL + '/user/order',{
         userName,
         bookId,
         num
      }
   )
 }
 export const orderGroup = (data:any) => {
   return axios.post(
      BASE_URL + '/user/orderGroup',data
   )
 }

 export const getUnsignedOrder = (userName:string):Promise<any> => {
   return axios.post (
      BASE_URL + '/user/getUnsignedOrder',
      {
         userName
      }
   )
 }

 export const getSignedOrder = (userName:string):Promise<any> => {
   return axios.post (
      BASE_URL + '/user/getSignedOrder',
      {
         userName
      }
   )
 }

 export const signedOrder = (id:number):Promise<any> => {
   return axios.get(
      BASE_URL + `/user/signed?id=${id}`
   )
 }
 export const changeNameApi = (data:any):Promise<any> => {
   return axios.post(
      BASE_URL + '/user/changeName',
      data
   )
 }
 export const changeAddrApi = (data:any):Promise<any> => {
   return axios.post(
      BASE_URL + '/user/changeAddr',
      data
   )
 }
 export const changePasswdApi = (data:any):Promise<any> => {
   return axios.post(
      BASE_URL + '/user/changePasswd',
      data
   )
 }
 
 export const changeRealNameApi = (data:any):Promise<any> => {
   return axios.post(
      BASE_URL + '/user/changeRealName',
      data
   )
 }

 export const changeNumberApi = (data:any):Promise<any> => {
   return axios.post(
      BASE_URL + '/user/changePhoneNumber',
      data
   )
 }

 export function adminLogin(data:any) {
   return axios.post(
      BASE_URL + '/user/adminLogin',
      data
   )
 }